import axios from "axios";

const baseURL = {
  "music-api": "http://localhost:3000/", //音乐api
};
axios.defaults.baseURL = baseURL["music-api"];
const url = {
  login: "/login/cellphone?phone=19983190679&password=19983190679",
  gethotsongs: "/search/hot", //热搜接口
  searchSuggest: "/search/suggest", //搜索建议接口
  getBanner: "/banner", //搜索建议接口
  recommended: "/personalized", //推荐歌单
  privatecontent: "/personalized/privatecontent", //独家放送
  newsong: "/personalized/newsong", //最新音乐
  mv: "personalized/mv", //推荐mv
  dj: "/dj/hot?limit=6", //主播电台
  detail: "/playlist/detail", //歌单详情
  comment: "/comment/playlist", //歌单评论
  albumcomment: "/comment/album", //专辑评论
  musicComment: "/comment/music", //歌曲评论
  hotcomment: "/comment/hot", //热门评论?id=186016&type=2
  subscribers: "/playlist/subscribers", //歌单收藏
  song: "/song/detail", //歌曲详情
  lyric: "/lyric", //歌词
  search: "/search", //搜索
  playlist: "/top/playlist", //精选歌单
  artists: "/artists", //单曲
  album: "/artist/album", //专辑
  albumcontent: "/album", //专辑内容
  ynamic: "/album/detail/dynamic", //专辑点赞info
  artistDesc: "/artist/desc", //专辑
  toplist: "/toplist", //全球榜
  myplaylist: "/user/playlist", //我的歌单
};
const login = () => {
  //热搜接口
  return axios.get(url.login).then((res) => res);
};
const gethotsongs = () => {
  //热搜接口
  return axios.get(url.gethotsongs).then((res) => res.data.result);
};
const searchSuggest = (data) => {
  //搜索建议接口
  return axios
    .get(url.searchSuggest, { params: data })
    .then((res) => res.data.result);
};
// getBanner: (data) => {
//     return request('/banner', data) //个性推荐轮播
//   },
const getBanner = (data) => {
  //搜索建议接口
  return axios
    .get(url.getBanner, { params: data })
    .then((res) => res.data.banners);
};
const getRecommend = (data) => {
  //推荐歌单
  return axios.get(url.recommended, { params: data }).then((res) => res.data);
};
const privatecontent = () => {
  //独家放送
  return axios.get(url.privatecontent).then((res) => res.data.result);
};
const newsong = () => {
  //最新推荐
  return axios.get(url.newsong).then((res) => res.data.result);
};
const getmv = () => {
  //mv推荐
  return axios.get(url.mv).then((res) => res.data.result);
};
const getdj = () => {
  //最新推荐
  return axios.get(url.dj).then((res) => res.data.djRadios);
};
const getdetail = (data) => {
  //歌单详情
  return axios
    .get(url.detail, { params: data })
    .then((res) => res.data.playlist);
};
const getcomment = (data) => {
  //评论
  return axios.get(url.comment, { params: data }).then((res) => res.data);
};
const musicComment = (data) => {
  //歌曲评论
  return axios.get(url.musicComment, { params: data }).then((res) => res.data);
};
const albumcomment = (data) => {
  //专辑评论
  return axios.get(url.albumcomment, { params: data }).then((res) => res.data);
};
const hotcomment = (data) => {
  //热门评论
  return axios.get(url.hotcomment, { params: data }).then((res) => res.data);
};
const subscribers = (data) => {
  //收藏者
  return axios
    .get(url.subscribers, { params: data })
    .then((res) => res.data.subscribers);
};
const song = (data) => {
  //歌曲详情
  return axios.get(url.song, { params: data }).then((res) => res.data.songs);
};
const lyric = (data) => {
  //歌词
  return axios
    .get(url.lyric, { params: data })
    .then((res) => res.data.lrc.lyric);
};
const search = (data) => {
  //搜索  playlist
  return axios.get(url.search, { params: data }).then((res) => res.data.result);
};
const playlist = (data) => {
  //歌词  playlist
  return axios.get(url.playlist, { params: data }).then((res) => res.data);
};
const artists = (data) => {
  //专辑
  return axios.get(url.artists, { params: data }).then((res) => res.data);
};
const album = (data) => {
  //专辑
  return axios.get(url.album, { params: data }).then((res) => res.data);
};
const artistDesc = (data) => {
  //歌手描述
  return axios.get(url.artistDesc, { params: data }).then((res) => res.data);
};
const toplist = () => {
  //全球榜
  return axios.get(url.toplist).then((res) => res.data);
};
const myplaylist = (data) => {
  //我的歌单
  return axios
    .get(url.myplaylist, { params: data })
    .then((res) => res.data.playlist);
};
const albumcontent = (data) => {
  //专辑内容
  return axios.get(url.albumcontent, { params: data }).then((res) => res.data);
};
const ynamic = (data) => {
  //专辑info
  return axios.get(url.ynamic, { params: data }).then((res) => res.data);
};
export default {
  install: function(Vue) {
    Vue.prototype.$api = {
      login,
      gethotsongs,
      searchSuggest,
      getBanner,
      getRecommend,
      privatecontent,
      newsong,
      getmv,
      getdj,
      getdetail,
      getcomment,
      hotcomment,
      subscribers,
      musicComment,
      song,
      lyric,
      search,
      playlist,
      toplist,
      myplaylist,
      album,
      artistDesc,
      artists,
      albumcomment,
      albumcontent,
      ynamic
    };
  },
};
